package com.example.demo.mapper;

import com.example.demo.entity.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;


@Repository
public interface CourseMapper extends JpaRepository<Course, String> {
    @Query(name="findByStatus",nativeQuery = true, value = "select * from course where cstatus = :cstatus")
    List<Course> findByStatus(String cstatus);

    @Query(name="findByCmname", nativeQuery = true, value = "select * from course where cmname = :cmname")
    List<Course> findByCmname(String cmname);

    @Query(name="findByTidAndStatus", nativeQuery = true, value="select * from course where tid=:tid and (cstatus=:cstatus1 or cstatus=:cstatus2 or cstatus=:cstatus3)")
    List<Course> findByTidAndStatus(String tid, String cstatus1, String cstatus2, String cstatus3);

    @Query(name="findByCmnameAndStatus", nativeQuery = true, value="select * from course where cmname=:cmname and (cstatus=:cstatus1 or cstatus=:cstatus2 or cstatus=:cstatus3)")
    List<Course> findByCmnameAndStatus(String cmname, String cstatus1, String cstatus2, String cstatus3);

    @Query(name="findByGroom", nativeQuery = true, value = "select * from course where croom = :croom")
    List<Course> findByCroom(String croom);

    @Query(name="findByTid", nativeQuery = true, value="select * from course where tid=:tid")
    List<Course> findByTid(String tid);

}


